from flask import Flask
from flask_admin import Admin, BaseView, expose
from flask_babelex import Babel
from flask_sqlalchemy import SQLAlchemy
from .views import init_views
from .model import db
from .user import jsondata
from .login import login_manager
import json
import os




def creat_app():
	app = Flask(__name__)
	#路由
	#app.register_blueprint(json,url_prefix='/json')

	app.config['SECRET_KEY'] = 'you never guess'
	#图片上传路径
	#UPLOAD_FOLDER = 'upload'
	app.config['UPLOAD_FOLDER'] = os.getcwd()+'/app/static/images/'
	#图片长度
	app.config['MAX_CONTENT_LENGTH'] = 40 * 1024 * 1024
	
	#后台管理页面
	
	app.register_blueprint(jsondata,url_prefix='/json')

	app.config['BABEL_DEFAULT_LOCALE'] = 'zh_CN'
	app.config['SQLALCHEMY_DATABASE_URI']="mysql+pymysql://root:123456@localhost/api"
	db.init_app(app)	
	login_manager.init_app(app)	
	init_views(app)
	 
	return app
